package com.itheima.service.impl;

import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
   private EmpMapper empMapper;

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Map getEmpJobData() {
        List<Map<String, Object>> list = empMapper.getEmpJobData();
        log.info("职位统计:职位名称-人数{}",list);
        Map map = new HashMap();
        map.put("jobList",list.stream().map(dataMap -> dataMap.get("pos")).toList());
        map.put("dataList",list.stream().map(dataMap -> dataMap.get("total")).toList());
        return map;
    }

    @Override
    public List<Map> getEmpGenderData() {
        List<Map> list = empMapper.getEmpGenderData();
        return list;
    }

    @Override
    public List<Map> getStuDegreeData() {
        List<Map> list = studentMapper.getStuDegreeData();
        return list;
    }

    @Override
    public Map getStuCountData() {
        List<Map> list = studentMapper.getStuCountData();
        log.info("班级人数统计:班级名称-人数{}",list);
        Map map = new HashMap();
        map.put("clazzList",list.stream().map(l -> l.get("clazzName")).toList());
        map.put("dataList",list.stream().map(l -> l.get("num")).toList());
        return map;
    }
}
